use std::sync::Arc;

use honeybee::prelude::*;
use honeybee::Result;

use super::room::Room;
use crate::room_manager::RoomManager;

pub struct RoomActor {
    room: Arc<Room>,
}

impl RoomActor {
    pub fn new(uid: u64, manager_addr: Addr<RoomManager>) -> Self {
        let room = Room::new(uid, manager_addr);
        Self { room }
    }
}

#[async_trait::async_trait]
impl Actor for RoomActor {
    fn name(&self) -> &str {
        "RoomActor"
    }

    async fn started(&mut self, ctx: &mut Context<Self>) -> Result<()> {
        info!("room actor:{} started", ctx.actor_id());
        Ok(())
    }

    async fn stopped(&mut self, _ctx: &mut Context<Self>) {
        info!("room actor stoped");
    }
}
